package com.atcc.test.designmodel.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;




public class ProxyHandler implements InvocationHandler{
	
	private Hello hello;
	
	public ProxyHandler(Hello hello) {
		this.hello = hello;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
		String start = df.format(new Date());
		System.out.println(method.getName()+"方法开始调用,当前时间时是:" + start);
		method.invoke(hello, args);
		String end = df.format(new Date());
		System.out.println(method.getName()+"方法调用结束,结束时间为:" + end);
		return null;
	}

}
